package com.xiaxiaoge.tutorialmod;

import com.mojang.logging.LogUtils;
import com.xiaxiaoge.tutorialmod.block.ModBlocks;
import com.xiaxiaoge.tutorialmod.entity.ModEntityTypes;
import com.xiaxiaoge.tutorialmod.entity.client.DiamonsurdRenderer;
import com.xiaxiaoge.tutorialmod.entity.client.DingDongChickenRenderer;
import com.xiaxiaoge.tutorialmod.entity.client.NewSnowManRenderer;
import com.xiaxiaoge.tutorialmod.entity.client.VictoriousSwiftTwoRenderer;
import com.xiaxiaoge.tutorialmod.items.ModItems;
import com.xiaxiaoge.tutorialmod.items.ModVehicleItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import software.bernie.geckolib3.GeckoLib;

/**
 *  主启动类
 * @author xsl
 */

@Mod(TutorialMod.MOD_ID)
public class TutorialMod
{
    public static final String MOD_ID = "tutorialmod";

    private static final Logger LOGGER = LogUtils.getLogger();

    public TutorialMod()
    {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        // 模型
        ModEntityTypes.register(modEventBus);
        // 注册物品事件总线
        ModItems.register(modEventBus);
        // 注册载具事件总线
        ModVehicleItems.register(modEventBus);
        // 注册方块事件总线
        ModBlocks.register(modEventBus);
        // GeckoLib 初始化
        GeckoLib.initialize();

        modEventBus.addListener(this::commonSetup);

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void commonSetup(final FMLCommonSetupEvent event)
    {

    }

    @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class ClientModEvents
    {
        @SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event)
        {
            // Some client setup code
            LOGGER.info("HELLO FROM CLIENT SETUP");
            LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
            EntityRenderers.register(ModEntityTypes.DIAMONSURD.get(), DiamonsurdRenderer::new);
            EntityRenderers.register(ModEntityTypes.NewSnowMan.get(), NewSnowManRenderer::new);
            EntityRenderers.register(ModEntityTypes.DING_DONG_CHICKEN.get(), DingDongChickenRenderer::new);
            EntityRenderers.register(ModEntityTypes.VICTORIOUS_SWIFT_TWO.get(), VictoriousSwiftTwoRenderer::new);
        }
    }


}
